package com.cloudptt.api.product.func.message;

import com.cloudptt.api.product.func.IFunc;
import com.cloudptt.api.product.func.call.CallAttr;
import com.cloudptt.api.product.log.Log;
import com.cloudptt.api.product.operator.MsgOperator;
import com.mcptt.config.local.SysConfig;
import com.mcptt.config.model.McIdInfo;
import com.mcptt.config.model.BootStrapSvrInfo;
import com.mcptt.db.DBAdapter;
import com.mcptt.db.model.AddrInfo;

import android.content.Context;

public class MsgFunc  implements IFunc
{
	public final static String Log_Key = "MsgAgent";
	private MsgBroadcast broadcast = null;
	private MsgOperator op = null;

	public MsgFunc(Context ctx, DBAdapter dbOperater, MsgOperator op, SysConfig config)
	{
		this.broadcast = new MsgBroadcast(ctx,dbOperater,op,config);
		this.op = op;
	}

	public void setMsgListener(MsgListener listener, AddrInfo curAddrInfo) {
		this.broadcast.setMsgListener(listener,curAddrInfo);
	}
	
	public void setNotifyListener(NotifyListener listener) {
		this.broadcast.setNotifyListener(listener);
	}
	public void setMsgSessionClass(Class cls)
	{
		this.broadcast.setMsgSessionClass(cls);
	}
	
	
	@Override
	public void onLogined(McIdInfo mcIdInfo, BootStrapSvrInfo info, boolean isLoginSuc) {
		// TODO Auto-generated method stub
	}
	@Override
	public void onPublishResult(int publishResult)
	{
		Log.d(Log_Key, "onPublishResult publishResult = " + publishResult);
		if((publishResult & CallAttr.McType_McData) != 0)
		{
			this.op.sendFdFindMessage();
		}
	}
	@Override
	public void onSubscribeCmsGmsResult(boolean isSuc,int mcType)
	{}
	@Override
	public void doNetworkChange(boolean isConn)
	{
		Log.d(Log_Key, "networkOffline isConn = " + isConn);
	}
	@Override
	public void doForceDetach()
	{
		Log.d(Log_Key, "doForceDetach");
	}
	@Override
	public void doLogout() {
		// TODO Auto-generated method stub
		Log.d(Log_Key, "doLogout");
	}
	@Override
	public void doExit()
	{
		this.broadcast.clearResource();
		this.broadcast = null;
	}

	@Override
	public void onLanChange(String lanType) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onKeepAlive(boolean isconnected) {
		// TODO Auto-generated method stub
		
	}
	

	
	
}
